Socket
Socket
Sign inDemoInstall

@types/use-sync-external-store

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/use-sync-external-store

TypeScript definitions for use-sync-external-store


Version published
Weekly downloads
4M
increased by7.4%
Maintainers
1
Weekly downloads
 
Created

What is @types/use-sync-external-store?

The @types/use-sync-external-store package provides TypeScript type definitions for the useSyncExternalStore hook, which is a part of React's experimental API for subscribing to external stores. This hook allows you to synchronize your component's state with an external store without causing unnecessary re-renders, making it particularly useful for integrating non-React state management libraries with React components.

What are @types/use-sync-external-store's main functionalities?

Type-safe integration with external stores

This code demonstrates how to create a custom hook that uses useSyncExternalStore to subscribe to an external store. The hook takes a store object with subscribe and getState methods, subscribes to the store, and returns the current state. TypeScript types ensure the integration is type-safe.

import { useSyncExternalStore } from 'use-sync-external-store';

function useCustomStore(store) {
  const state = useSyncExternalStore(
    store.subscribe,
    store.getState
  );
  return state;
}

Other packages similar to @types/use-sync-external-store

FAQs

Package last updated on 03 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc